﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.Mvc;

namespace MvcMovie.Filters
{
    public class LogAttribute : ActionFilterAttribute
    {
        public string Message { get; set; }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            string log = filterContext.HttpContext.User.Identity.Name + " " + Message + " " + filterContext.ActionDescriptor.ActionName + " " + DateTime.Now.ToString("dd/MM/yyyy h:mm:tt");

            using (var writer = new FileInfo(@"C:\Documents and Settings\Administrador\Desktop\ForFun\c#\log.txt").AppendText())
            {
                writer.WriteLine(log);
            }
        }
    }
}